package com.wastill.websocket.controller;

import com.wastill.websocket.dto.MessageBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.simp.SimpMessageSendingOperations;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * @author: xujiang
 * @createTime: 2020/12/25 18:26
 */
@Controller
public class MessageController {
    @Autowired
    private SimpMessageSendingOperations simpMessageSendingOperations;

    @MessageMapping("/test")
    public void sendTopicMessage(MessageBody messageBody) {
        simpMessageSendingOperations.convertAndSend(messageBody.getDestination(), messageBody);
    }
}

